package com.ayu.shortlink.engine.controller;

import com.ayu.shortlink.engine.common.convention.result.Result;
import com.ayu.shortlink.engine.common.convention.result.Results;
import com.ayu.shortlink.engine.dto.req.CouponTemplateRemindCancelReqDTO;
import com.ayu.shortlink.engine.dto.req.CouponTemplateRemindCreateReqDTO;
import com.ayu.shortlink.engine.dto.req.CouponTemplateRemindFindAllReqDTO;
import com.ayu.shortlink.engine.dto.resp.CouponTemplateRemindFindAllRespDTO;
import com.ayu.shortlink.engine.service.CouponTemplateRemindService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 优惠券提醒控制器
 */
@RestController
@RequiredArgsConstructor
public class CouponTemplateRemindController {
    private final CouponTemplateRemindService couponTemplateRemindService;

    /**
     * 用户预约抢优惠券
     */
    @PostMapping("/api/short-link/engine/v1/user-template-remind/create")
    public Result<Void> createCouponRemind(@RequestBody CouponTemplateRemindCreateReqDTO requestParam){
        couponTemplateRemindService.createCouponRemind(requestParam);
        return Results.success();
    }

    /**
     * 用户预约抢优惠券V2
     */
    @PostMapping("/api/short-link/engine/v2/user-template-remind/create")
    public Result<Void> createCouponRemind2(@RequestBody CouponTemplateRemindCreateReqDTO requestParam){
        couponTemplateRemindService.createCouponRemind2(requestParam);
        return Results.success();
    }

    /**
     * 用户取消预约
     */
    @DeleteMapping("/api/short-link/engine/v1/user-template-remind/cancel")
    public Result<Void> cancelCouponRemind(@RequestBody CouponTemplateRemindCancelReqDTO requestParam){
        couponTemplateRemindService.cancelCouponRemind(requestParam);
        return Results.success();
    }

    /**
     * 用户查看所有预约信息
     */
    @GetMapping("/api/short-link/engine/v1/user-template-remind/findAll")
    public Result<List<CouponTemplateRemindFindAllRespDTO>> findAllCouponRemind(CouponTemplateRemindFindAllReqDTO requestParam){
        return Results.success(couponTemplateRemindService.findAllCouponRemind(requestParam));
    }
}
